﻿using Candy.Infrastructure;
using System;
using System.Windows;
using System.Windows.Controls;

namespace Candy
{
    public partial class ConfirmationWindow : ChildWindow, IConfirmationControl
    {
        public ConfirmationWindow()
        {
            InitializeComponent();
            base.HasCloseButton = false;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = true;
            this.Close();

            if (_callback != null)
            {
                _callback(true);
            }
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
            this.Close();
 
            if (_callback != null)
            {
                _callback(false);
            }
        }



        Action<bool> _callback;
        public void ConfirmAction(Action<bool> callback, string message)
        {
            this.DialogResult = null;
            messageTextBlock.Text = message;
            _callback = callback;
            this.Show();
        }
    }
}

